#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    QMessageBox* messagebox = new QMessageBox(this);
    messagebox->setWindowTitle("这是一个messagebox");
    messagebox->setText("这是对话框的文本");
    messagebox->setIcon(QMessageBox::Warning);
    messagebox->setStandardButtons(QMessageBox::Ok | QMessageBox::Save | QMessageBox::Cancel);
    //QPushButton* button = new QPushButton("确定", messagebox);
    //messagebox->addButton(button, QMessageBox::AcceptRole);
    int result = messagebox->exec();
    if(result == QMessageBox::Ok){
        qDebug() << "ok" << endl;
    }
    else if(result == QMessageBox::Save){
        qDebug() << "save" << endl;
    }
    else if(result == QMessageBox::Cancel){
        qDebug() << "cancel" << endl;
    }
    delete messagebox;
}
